package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.DmsPullTeaDataService;
import com.yunhai.model.entity.dms.DmsPullTeaDataEntity;
import com.yunhai.model.vo.dms.DmsPullTeaDataQuery;
import com.yunhai.model.vo.dms.DmsPullTeaDataVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/pullTeaData")
public class DmsPullTeaDataController {

    @Resource
    private DmsPullTeaDataService dmsPullTeaDataService;


    /**
     * 获取 DmsPullTeaData 分页列表
     */
    @GetMapping("/pagination")
    public Ret getDmsPullTeaDataPagination(PaginationVo paginationVo, DmsPullTeaDataQuery dmsPullTeaDataQuery ) throws Exception {
        IPage page = dmsPullTeaDataService.getDmsPullTeaDataPagination(paginationVo, dmsPullTeaDataQuery );
        return Ret.toPage(page);
    }


    /**
     * 获取 DmsPullTeaData 所有数据
     */
    @GetMapping("/all")
    public Ret getDmsPullTeaDataAllList( DmsPullTeaDataQuery dmsPullTeaDataQuery ) throws Exception {
        List<DmsPullTeaDataEntity> list = dmsPullTeaDataService.getDmsPullTeaDataAllList( dmsPullTeaDataQuery );
        return Ret.ok(list);
    }



    /**
     * 获取 DmsPullTeaData 详情
    */
   @GetMapping("/{id}")
   public Ret getDmsPullTeaDataDetail(@PathVariable Long id) throws Exception {

       DmsPullTeaDataEntity dmsPullTeaData = dmsPullTeaDataService.getDmsPullTeaDataDetail(id);
       return Ret.ok(dmsPullTeaData);
   }


    /**
     * 新增 DmsPullTeaData
     * */
    @PostMapping("")
    public Ret addDmsPullTeaData(@RequestBody DmsPullTeaDataVo dmsPullTeaDataVo) throws Exception {

        dmsPullTeaDataService.addDmsPullTeaData(dmsPullTeaDataVo);
        return Ret.ok();
    }


    /**
     * 更新 DmsPullTeaData
     * */
    @PutMapping("")
    public Ret updateDmsPullTeaData(@RequestBody DmsPullTeaDataVo dmsPullTeaDataVo) throws Exception {

        dmsPullTeaDataService.updateDmsPullTeaData(dmsPullTeaDataVo);
        return Ret.ok();
    }


    /**
     * 删除 DmsPullTeaData
     * */
    @PostMapping("/batchRemove")
    public Ret batchRemoveDmsPullTeaData( @RequestBody List<Long> ids ) throws Exception {

        dmsPullTeaDataService.batchRemoveDmsPullTeaData(ids);
        return Ret.ok();
    }
}

  